<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	  xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Instituto Missionário de Ensino El Shaday</title>
<link rel="stylesheet" href="css/gemepde.css"  />
</h:head>
<h:body styleClass="conf-pagina">
	
	<script type="text/javascript">
		function start() {
			PF('statusDialog').show();
		}

		function stop() {
			PF('statusDialog').hide();
		}
	</script>

<p:dialog modal="true" widgetVar="statusDialog" header="Status" draggable="false" closable="false" resizable="false">  
    <p:graphicImage value="/design/ajaxloadingbar.gif" />  
</p:dialog>

<p:layout fullPage="true">
	<p:growl id="messages" showDetail="false" />  
	<p:layoutUnit position="north" size="180" style="background: transparent !important;">
		<p:layout>
		<div align="center">
			<!-- LOGO -->
			<p:layoutUnit position="west" size="200" style="background: transparent !important;"> 
            	<p:graphicImage value="/images/background-gemepde.jpg" height="150px" />
            </p:layoutUnit>
               
			<!-- CABECALHO -->
               <p:layoutUnit position="center" id="layoutCabecalho" style="background: transparent !important;">
                   <h:form id="formExibCab" >
                   	<p:panelGrid>
						<p:row>
							<p:column>
								<h:outputText id="textCabecalho" value="#{cabecalhoBean.cabecalho.conteudo}" escape="false"/>
							</p:column>
							<p:column>
								<p:commandButton icon="ui-icon-pencil" id="btnEditarCab" update="@([id$=editarCabecalhoDialog])" 
									oncomplete="dialogEditarCabecalho.show();" action="#{cabecalhoBean.editarCabecalho}" value="Alterar"/>
							</p:column>
						</p:row>
					</p:panelGrid>
					
				</h:form>
               </p:layoutUnit>
               </div>
		</p:layout>
	</p:layoutUnit>
	
	<!-- MENU -->
	<p:layoutUnit position="west" size="204" style="background: transparent !important;">
		<div align="center">
			<h:form id="formMenu">
				<p:menu style="width: 11.5em;">
					<p:submenu label="Menu">
						<p:menuitem value="Novo Aluno" icon="ui-icon-plusthick"	action="#{alunoBean.novoAluno}" ajax="false" />
						<p:menuitem value="Download Backup" ajax="false" onclick="PrimeFaces.monitorDownload(start, stop)"   
							        icon="ui-icon-circle-arrow-s">  
							    <p:fileDownload value="#{alunoBean.arquivoBackup}" />  
						</p:menuitem>
					</p:submenu>	
				</p:menu>
			</h:form>
		</div>
	</p:layoutUnit>
	
	<p:layoutUnit position="center" style="background: transparent !important;">
		<!-- PESQUISA -->
		<h:form id="formPesquisar" style="background: transparent !important;">
			<p:panel header="Área de Pesquisa" style="background: transparent !important;">
				<p:panelGrid columns="2">
					<h:outputLabel for="matricula-filter" value="Matrícula: " />
					<p:inputText id="matricula-filter" size="30"
						value="#{alunoBean.alunoFilter.matriculaFilter}" />

					<h:outputLabel for="nome-filter" value="Nome: " />
					<p:inputText id="nome-filter" size="80"
						value="#{alunoBean.alunoFilter.nomeFilter}" />

					<h:inputHidden />
					<p:commandButton value="Buscar" icon="ui-icon-search"
						action="#{alunoBean.procurarAluno()}"
						update=":formResultado:dataTableBusca" />
				</p:panelGrid>
			</p:panel>
		</h:form>
		
		<!-- TABELA DE RESULTADO -->
		<h:form id="formResultado" style="background: transparent !important;">
			<p:panel header="Resultado" style="background: transparent !important;">
				<p:dataTable id="dataTableBusca" paginator="true" rows="5"
					var="aluno" value="#{alunoBean.resultadoDaBusca}"
					paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rowsPerPageTemplate="5,10,15">

					<p:column width="20%">
						<f:facet name="header">
							<h:outputLabel value="Matricula" />
						</f:facet>
						<h:outputText value="#{aluno.matricula}" />
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputLabel value="Nome" />
						</f:facet>
						<h:outputText value="#{aluno.nome}" />
					</p:column>

					<p:column width="10%">
						<f:facet name="header">
							<h:outputLabel value="Editar" />
						</f:facet>
						<div align="center">
							<h:form>
								<p:commandButton icon="ui-icon-pencil" action="#{alunoBean.editarAluno}" ajax="false">
									<f:param name="aluno" value="#{aluno}" />
								</p:commandButton>
							</h:form>
						</div>
					</p:column>

					<p:column width="10%">
						<f:facet name="header">
							<h:outputLabel value="Excluir" />
						</f:facet>
						<div align="center">
							<p:commandButton icon="ui-icon-trash" action="#{alunoBean.deletarAluno}" ajax="false">
								<f:param name="aluno" value="#{aluno}" />
							</p:commandButton>
						</div>
					</p:column>

					<p:column width="10%">
						<f:facet name="header">
							<h:outputLabel value="Imprimir" />
						</f:facet>
						<div align="center">
							<p:commandButton icon="ui-icon-print" oncomplete="dialogImprimirAluno.show();">
								<f:param name="aluno" value="#{aluno}" />
							</p:commandButton>
						</div>
					</p:column>
				</p:dataTable>
			</p:panel>
		</h:form>

	</p:layoutUnit>
</p:layout>

<!-- 	EDITAR CABEÇALHO -->
<p:dialog widgetVar="dialogEditarCabecalho" modal="true" header="Editar Cabeçalho"
	width="530" showEffect="fade" hideEffect="fade" resizable="false" id="editarCabecalhoDialog">
	<h:form id="formEditCab">
		<p:editor widgetVar="editor" value="#{cabecalhoBean.conteudoCabecalho}" width="500"
			controls="bold italic underline font size color alignleft center alignright justify undo redo cut copy paste"/>

		<p:separator />
		<p:commandButton value="Cancelar" onclick="dialogEditarCabecalho.hide()" type="button" />
		<p:commandButton value="Salvar" oncomplete="dialogEditarCabecalho.hide()" actionListener="#{cabecalhoBean.salvarCabecalho()}" update="@([id$=textCabecalho])" />
	</h:form>
</p:dialog>

<!-- 	IMPRIMIR ALUNO -->
<p:dialog widgetVar="dialogImprimirAluno" modal="true" header="Imprimir Aluno"
	width="570" showEffect="fade" hideEffect="fade" resizable="false" id="imprimirAlunoDialog">
	<h:form id="formImprimir">
		<h:panelGrid border="0" style="margin-bottom:10px" cellpadding="5" columns="2">
			<h:outputLabel value="Adicionar cabeçalho à impressão?" />
			<p:selectBooleanButton value="#{alunoBean.adicionarCabecalho}" onLabel="Sim" offLabel="Não" />
			<h:outputLabel value="Deseja imprimir o aluno(a) " />
			<h:outputLabel value="#{alunoBean.alunoImprimir.nome} ? " style="font-weight: bold;" />
		</h:panelGrid>

		<p:separator />
		<p:commandButton value="Cancelar" onclick="dialogImprimirAluno.hide()" type="button" />
		<p:commandButton value="Imprimir" icon="ui-icon-print" oncomplete="dialogImprimirAluno.hide();">
			<p:printer target="@([id$=dialogEditarCabecalho])" />
		</p:commandButton>
	</h:form>
</p:dialog>
</h:body>
</html>